<template>
	<view class="page">
		
		<view class="goods-list">
			<view class="list" v-for="(item,index) in goodsList" :key="index" v-if="goodsList.length!=0">
				<view class="check" :style="isEdit?'display: flex':'display: none'">
					<text class="iconfont icon-check"></text>
				</view>
				<view class="thumb">
					<image :src="item.cover" mode=""></image>
				</view>
				<view class="item">
					<view class="title">
						<text class="two-omit">{{item.store_name}}</text>
					</view>
					<view class="price-more">
						<view class="price">{{item.intro}}</view>
					</view>
					<view class="goods-btn">
						<view class="btn" @click="onAttention(item)">
							<text>取消关注</text>
						</view>
						<view class="cart" @click="go_url('/pages/dianpu/dianpu?id='+item.store_id)">
							<text class="iconfont icon-cart"></text>
						</view>
					</view>
				</view>
			</view>
			<view class="empty-box" v-if="goodsList.length==0">
				<image src="/static/ic_nodata.png" mode=""></image>
				<view class="">暂无数据</view>
			</view>
		</view>
		<view class="footer-btn" :style="isEdit?'display: flex':'display: none'">
			<view class="btn">取消关注</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isEdit: false,
				page:1,
				goodsList:[]
			};
		},
		onShow() {
			this.page=1
			this.goodsList=[]
			this.getList()
		},
		onReachBottom(){
			this.page++
			this.getList()
		},
		methods:{
			getList(){
				let that = this
				that.tui.request("api.auth.order/StoreAttentionList", "POST", {page:that.page}, false, false, true).then((res) => {
					if(res.code==1){
						that.goodsList = that.goodsList.concat(res.data.list)
					}
				}).catch((res) => {
					
				})
			},
			go_url(e){
				this.tui.href(e)
			},
			onAttention(e) {
				let that = this
				that.tui.request("api.auth.order/StoreAttention", "POST", {store_id:e.store_id,type:2}, false, false, true).then((res) => {
					that.tui.toast(res.info)
					if(res.code==1){
						that.page=1
						that.goodsList=[]
						that.getList()
					}
				}).catch((res) => {
					
				})
			},
			
		}
	}
</script>

<style scoped lang="scss">
	@import 'GoodsOn.scss';
</style>
